fix: delegate execution and tab completion of ignored commands to original plugins#3
Open
NoltoxGit wants to merge 5 commits into
Open
fix: delegate execution and tab completion of ignored commands to original plugins#3NoltoxGit wants to merge 5 commits into
NoltoxGit wants to merge 5 commits into
Conversation
HSGamer
requested changes
Jun 7, 2026
| @SuppressWarnings("unchecked") | ||
| private Map<String, Command> getKnownCommands() { | ||
| try { | ||
| Field field = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap"); |
Member
There was a problem hiding this comment.
It's no longer a good way to get the commandMap.
https://github.com/ProjectUnified/MineLib/blob/master/plugin/plugin-command/src/main/java/io/github/projectunified/minelib/plugin/command/CommandComponent.java
… and tab completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request resolves a conflict where BetterGUI shadows command labels from other plugins (such as LMBishop's Quests plugin aliases
/q,/quest, and/quests) and breaks both their command execution and native tab completion.The Bug & Root Cause:
BetterGUI's
MenuCommandManagerregisters dynamic menu commands in Bukkit'sSimpleCommandMapduring server startup. For plugins that declare aliases:PlayerCommandPreprocessEvent, the event was not cancelled, leading Bukkit to execute the command currently residing in the map (BetterGUI's menu command, opening the menu).Solution:
This PR implements a non-intrusive, single-file bug fix inside
CommandListener.java:PlayerCommandPreprocessEvent(for execution) andTabCompleteEvent(for autocompletion).findAlternativeCommand):knownCommands) to find the shadowed original command (e.g.,quests:qorquests:questregistered with the plugin namespace).event.setCompletions(...)only if a shadowed native command was resolved.This approach ensures compatibility with Bukkit/Spigot/Paper from 1.9 up to modern versions, keeping the addon extremely simple and cohesive.